/*
 * Copyright (C) 2015  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


#include "PlanetWars2dRT-core/specific/controller/game_end_messages.h"
#include <string.h>


EXTERN_C_BEGIN


char*
game_end_message_winner_with_name_unsafe(const char* player_name)
{
  size_t message_size = strlen(player_name) + 5 + 1;
  char* message = (char*) malloc(message_size * sizeof(char));
  strcpy(message, player_name);
  strcat(message, " wins");
  return message;
}

char*
game_end_message_winner_with_name(const char* player_name)
{
  return
    player_name == NULL
    ? NULL
    : game_end_message_winner_with_name_unsafe(player_name);
}

char*
game_end_message_winner_with_player(const player_t* player)
{
  return game_end_message_winner_with_name(player_get_name(player));
}


EXTERN_C_END
